package com.AJava1710D.xianchengchi;

import com.AJava1710D.xiancheng.CallAbleAA;

import java.util.concurrent.*;

/**
 * 作者: LCG
 * 日期: 2020/6/23 09:45
 * 描述:
 */
public class Test01XianChegChi {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        LinkedBlockingQueue<Runnable> linkedBlockingQueue=new LinkedBlockingQueue<>();

        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(4,//核心线程数
                                                                6,//最大线程数
                                                                60, //线程存活时间
                                                                TimeUnit.SECONDS, //线程存活时间的单位
                                                                linkedBlockingQueue); //工作队列



        threadPoolExecutor.execute(new RunableExec());


        threadPoolExecutor.shutdown();


        /*ArrayBlockingQueue<Runnable> arrayBlockingQueue= new ArrayBlockingQueue<>(2);

        LinkedBlockingQueue<Runnable> linkedBlockingQueue=new LinkedBlockingQueue<>();

        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(2,//核心线程数
                2,//最大线程数
                60, //线程存活时间
                TimeUnit.SECONDS, //线程存活时间的单位
                arrayBlockingQueue,
                new MyRejectImpl(linkedBlockingQueue)); //工作队列


        for (int i=0;i<5;i++){
            threadPoolExecutor.execute(new RunableExec1(i));
        }*/

        //使用定长的线程池
       /* ExecutorService executorService = Executors.newFixedThreadPool(1);

        FutureTask<String> futureTask=new FutureTask<String>(new CallAbleAA());

        executorService.submit(futureTask);

        String s = futureTask.get();

        System.out.println(s);*/


        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);

        scheduledExecutorService.scheduleAtFixedRate(new RunableExec1(1),0,2,TimeUnit.SECONDS);





    }

}
